//
//  SelectionConsultationViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/2/5.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "SelectionConsultationViewController.h"
#import "SelectionConsultationView.h"
#import "ReleaseAdviceViewController.h"
#import "souSuoViewController.h"

@interface SelectionConsultationViewController ()
@property(nonatomic,strong)SelectionConsultationView *aView;
@end

@implementation SelectionConsultationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"精选咨询";
    
    UIBarButtonItem *pulishButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"发布"] style:UIBarButtonItemStylePlain target:self action:@selector(fabu)];
    
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"搜索"] style:UIBarButtonItemStylePlain target:self action:@selector(souSuo)];
    
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:saveButton,pulishButton,nil]];

    
    _aView=[SelectionConsultationView new];
    [self.view addSubview:_aView];
    [_aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    _aView.titleArr=[NSMutableArray arrayWithCapacity:0];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"",@"ct_id",@"全部",@"ct_name", nil];
    [_aView.titleArr addObject:dic];
    _aView.dataArr=[NSMutableArray arrayWithCapacity:0];
    _aView.viewController=self;
    [self loginView];
}

-(void)fabu{
    ReleaseAdviceViewController *viewController=[[ReleaseAdviceViewController alloc] init];
    [ZQTools pushNextViewController:self andRootController:viewController];
}
-(void)souSuo{
    souSuoViewController *souSuo=[[souSuoViewController alloc] init];
    souSuo.abc=1;
    [ZQTools pushNextViewController:self  andRootController:souSuo];
}
-(void)loginView{
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/case_type" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        NSArray *typeArr=responseObject;
        [_aView.titleArr addObjectsFromArray:typeArr];
        [self loadDate];
    } anderrorBlock:nil];
    
}
-(void)loadDate{
    NSDictionary *typeDic=_aView.titleArr[0];
    NSNumber *nt_id=[typeDic objectForKey:@"ct_id"];
    NSString *news_nt_id=[NSString stringWithFormat:@"%@",nt_id];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:news_nt_id,@"ct_id",@"1",@"page",@"10",@"pagesize", nil];
    [ZQTools AFNPostDataUrl:@"user/consult/select_consult" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        
        NSArray *typeArr=responseObject;
        _aView.dataArr=[NSMutableArray arrayWithArray:typeArr];
        [_aView creatView];
    } anderrorBlock:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
